package Gateway;

use strict;

use Utils;

use Host;

use base qw (NetworkDB);

#use base qw/BaseClass/;	# deprecated - z dob pred Class::DBI, 2.7.2005

__PACKAGE__->set_up_table('gateways');
__PACKAGE__->has_many(segments => 'Segment');


sub initialize {
	my $self = shift;
}

sub command {
	my $self = shift;
	my ($command) = @_;
	my $user = $self->default_user;
	my $IP = $self->mgmt_ip;
#	print "sudo -u $user ssh $user\@$IP '$command'";
	my @output_lines = `sudo -u $user ssh $user\@$IP '$command'`;
	return @output_lines;
}

sub send_file {
        my $self = shift;
        my ($src_local_file, $dst_remote_file) = @_;
#	if (($dst_remote_file eq undef) || !$dst_remote_file) {
#		$dst_remote_file = $src_remote_file;
#	}
        my $user = $self->default_user;
        my $IP = $self->mgmt_ip;
        my @output_lines = `sudo -u $user scp -r $src_local_file $user\@$IP\:$dst_remote_file`;
        return @output_lines;
}

#sub get_file {
#	my $self = shift;
#	my ($src_remote_file, $dst_local_file) = @_;
#	my $user = $self->default_user;
#	my $IP = $self->mgmt_ip;
#	my @output_lines = `sudo -u $user scp -r $user\@$IP\:$src_remote_file $dst_local_file`;
#	return @output_lines;
#}

#########################
package Gateway::Routing;

#############################
package Gateway::Firewalling;

#############################
package Gateway::Accounting;

# riesene iptables skriptom vygenerovanym zo Segment.pm priamo na firewall
#sub reset_counters {
#	my $self = shift;
#	my ($chain) = @_;
#	$self->command("sudo iptables -Z");
#	my @hosts = Host->retrieve_all;	
#	foreach my $host (@hosts) {
#		$host->bytes_in(0);
#		$host->bytes_ex(0);
#		$host->bytes_in_base(0);
#		$host->bytes_ex_base(0);
#		$host->update;
#		
#	}
#}


1;
